<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/echarts/5.3.3/echarts.min.js"></script>
</head>
<body>
    <div id="main" style="height: 600px;"></div>
    <script type="text/javascript">
        var myChart = echarts.init(document.getElementById('main'));
        var xDataArr = ['张三','李四','王五','闰土','小明','茅台','二妞','大强'];
        var yDataArr = [88,92,63,77,94,80,72,86];
        var option = {
            title:{
                text:"成绩展示",
                textStyle:{
                     color:"red",
                },
                borderWidth:1,
                borderColor:"pink",
                borderRadius:10,
                left:'center',
                top:'top'
            },
            toolbox: {
                feature: {
                    saveAsImage: {}, // 导出图片
                    dataView: {readOnly: false}, // 数据视图
                    magicType: {type: ['line', 'bar', 'stack', 'tiled']}, // 动态类型切换
                    restore: {}, // 重置
                    dataZoom: {} // 数据区域缩放
                }
            },
            tooltip: {
                trigger: 'item', // 设置触发类型为'item'，即悬停在柱子上时显示提示框
                triggerOn: 'mousemove', // 设置触发时机为鼠标移动时
                formatter: function (params) {
            // 格式化提示框内容
                 return '学生：' + params.name + '<br/>成绩：' + params.value;
                }
            },
            xAxis:{
                type:"category",
                data:xDataArr
            },
            yAxis:{
                type:'value',
            },
            series: [{
                name: '成绩',
                type: 'bar',
                data: yDataArr
                }
            ]
        }
        myChart.setOption(option);
    </script>
</body>
</html>